<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ include file="commons/taglibs.jsp" %>
<!DOCTYPE html>
<!-- saved from url=(0026)http://sell.fqapps.com/reg -->
<html class="js cssanimations"><head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1,minimum-scale=1,user-scalable=no">
    <title>云产品库-一折微信淘客系统</title>

    <link rel="stylesheet" type="text/css" href="${ctx}/assets/css/amazeui.css">
    <link rel="stylesheet" type="text/css" href="${ctx}/assets/css/admin.css">
    <link rel="stylesheet" type="text/css" href="${ctx}/assets/css/style.css">
	<link rel="stylesheet" type="text/css" href="${ctx}/assets/css/library.css">
    <link href="${ctx}/assets/plugins/pagination/pagination.css" type="text/css" rel="stylesheet"/>
    <!--[if (gte IE 9)|!(IE)]><!-->

    <script type="text/javascript" src="${ctx}/assets/js/jquery.min.js"></script>
    <script type="text/javascript" src="${ctx}/assets/js/fastclick.min.js"></script>
    <script>$(function() {FastClick.attach(document.body);});</script>
    <!--<![endif]-->

    <script type="text/javascript" src="${ctx}/assets/js/amazeui.min.js"></script>
	<script type="text/javascript" src="${ctx}/assets/js/library.js"></script>
	<script src="${ctx}/assets/plugins/layer/layer.js"></script>
	<script src="${ctx}/assets/plugins/pagination/jquery.pagination.js"></script>

</head>


<body>
<%@ include file="commons/dialog.jsp" %>
<jsp:include page="commons/head.jsp" flush="true" />


<script>
$(function(){

	getData();

	//综合
	$("#all").on('click', function () {
		param.sort = "";
		getData();
    });
	//销量最高
	$("#order_by_sales").on('click', function () {
		param.sort = "total_sales_des";
		getData();
    });
	//佣金最高
	$("#order_by_commission").on('click', function () {
		param.sort = "tk_total_commi_des";
		getData();
    });
	//佣金比率最高
	$("#order_by_commissionrate").on('click', function () {
		param.sort = "tk_rate_des";
		getData();
    });
	//筛选商品
	$("#search_by_scope").on('click', function () {
		param.start_price = $('#itemendprice_min').val();
		param.end_price = $('#itemendprice_max').val();
		getData();
    });
	//搜索商品
	$("#search_button").on('click', function () {
		param.q = $('#search_input').val();
		getData();
    });
	//提交天猫店数据
	$('#tianmao').click(function(){ 
		if($('#tianmao').is(':checked')) { 
			param.is_tmall = true;
		} else {
			param.is_tmall = false;
		}
		getData();
	});
//提交选品
$('#btn_items_select,.button1').click(function(){
    var select_items_data = "";
    if($(this).hasClass('button1')){
        $(this).children().text('已推广');
        $(this).children().css('color','rgb(208, 208, 208)');
        $(this).attr('disabled','disabled');
        $(this).parent().siblings('.button').children().text('已选取');
        $(this).parent().siblings('.button').children().css('color','rgb(208, 208, 208)');
        $(this).parent().siblings('.button').attr('disabled','disabled');
        var id=$(this).parent().siblings('.button').attr('id');
        var a = $('.product_button_i');
        var b = a.length;
        for(var i = 0;i<b;i++){
            var dataid=a.eq(i).attr('data-id');
            if(dataid==id){
                $('i[data-id='+dataid+']').parents(".product").remove();

            }
        }
        var product = $(".product");
        $(".buy_number span").text(product.length);
        var itemslist = $(this).parent().siblings(".itemsdata");
        select_items_data = select_items_data + '{"itemtitle":"'+itemslist.data('itemtitle')+'","itemid":"'+itemslist.data('itemid')+'","couponurl":"'+itemslist.data('couponurl')+'","itemdesc":"'+itemslist.data('itemdesc')+'","itemprice":"'+itemslist.data('itemprice')+'","itemendprice":"'+itemslist.data('itemendprice')+'","tkrates":"'+itemslist.data('tkrates')+'"}';
        var itemid=$(this).parent().siblings('.button').attr('data-itemid');
    }else{
        var a = $('.product_button_i');
        var b = a.length;
        for(var i = 0;i<b;i++){
            var id=a.eq(i).attr('data-id');
            $('#'+id).siblings().find('.button1').children().html('已推广');
            $('#'+id).siblings().find('.button1').children().css('color','rgb(208, 208, 208)');
            $('#'+id).siblings().find('.button1').attr('disabled','disabled');
            var itemid=$('#'+id).attr('data-itemid');
            //console.log(itemid);
        }
        
        //产品数据写入隐藏域
    	var itemslist = $(".buy_car_main").children().find(".itemsdata");
    	var count = itemslist.size();
    	var split_str = ",";
    	
    	for (var i=0;i<count;i++){
    		if(i == count-1){
    			split_str = "";
    		}
    		select_items_data = select_items_data + '{"itemtitle":"'+itemslist.eq(i).data('itemtitle')+'","itemid":"'+itemslist.eq(i).data('itemid')+'","couponurl":"'+itemslist.eq(i).data('couponurl')+'","itemdesc":"'+itemslist.eq(i).data('itemdesc')+'","itemprice":"'+itemslist.eq(i).data('itemprice')+'","itemendprice":"'+itemslist.eq(i).data('itemendprice')+'","tkrates":"'+itemslist.eq(i).data('tkrates')+'"}'+split_str;
    	}
    }
	select_items_data = '['+select_items_data+']';
	
	$.ajax({
		type:'post',
		url:"/library/api_cloud_items_select.html",
		data:{'select_items_data':select_items_data,'itemid':itemid},
		success:function(data){
			$(".buy_car_background").hide();
			$("#fq_alert_info").html(data.info);
			$('#fq_alert').modal({closeViaDimmer:false});
			
			if(data.status == 1){
				var iframe = document.createElement('iframe');iframe.height = 0;iframe.width = 0;iframe.src="fqapps://function=cloud_items_select_update";document.body.appendChild(iframe);
                $('.product_button_i').parents(".product").remove();
                var number=0;
                $(".buy_number span").text(number);
			}
			
		}
	});

});

});
this.getData = function(){
    pageCallBack(0);
};
var param = {};
//param.q = "男装";
param.cat = "16,18,19";
//param.itemloc = "合肥";
param.page_size = 30;
//查询产品库数据
function pageCallBack(index) {
	layer_index = layer.load();
    param.page_no = parseInt(index) + 1;
	$.ajax({
		type : 'post',
		url : "${ctx}/product/cloudProductList.do",
		data : param,
		async : true,
		success : function(data){
			layer.close(layer_index);
		    var total = data.data.tbk_item_get_response.total_results;
            if (index == 0) {
				$("#Pagination").pagination(total, {
					callback : pageCallBack,
					prev_text : "上一页",
					next_text : "下一页 ",
					items_per_page : param.page_size,
					num_edge_entries : 2, //两侧首尾分页条目数
					num_display_entries : 3, //连续分页主体部分分页条目数
					current_page : index //当前页索引
				});
			}
			creatHtml(data.data);
		}
	});
}

function creatHtml(list){
	var html=[];
	var n_tbk_item = list.tbk_item_get_response.results.n_tbk_item;
	for(var i = 0;i<n_tbk_item.length;i++){
		html.push("<li>");
		html.push("<div class='library_list am-margin-horizontal-xs'>");
		html.push("<div class='am-hide itemsdata' data-itemtitle='" + n_tbk_item[i].title + "' data-itemid='" + n_tbk_item[i].num_iid + "' data-couponurl='" + n_tbk_item[i].item_url + "' data-itemdesc='' data-itemprice='" + n_tbk_item[i].reserve_price + "' data-itemendprice='" + n_tbk_item[i].zk_final_price + "' data-tkrates='50.30'></div>");
		html.push("<div class='today'><span>TOP " + (i+1) + "</span></div><a target='_blank' href='" + n_tbk_item[i].item_url + "'><img src='" + n_tbk_item[i].pict_url + "' class='img_loadend' style='display: inline;'></a>");
		html.push("<div class='img_loading' style='display: none;'><i class='am-icon-spinner am-icon-pulse am-icon-sm' style='margin-top:50%;'></i></div><div class='commodity_name'><a target='_blank' href='" + n_tbk_item[i].item_url + "'><img src='${ctx}/assets/files/commodity_logo.png'><p>" + n_tbk_item[i].title + "</p></a></div>");
		html.push("<div class='library_money'><span>劵后</span><b>" + n_tbk_item[i].zk_final_price + "</b><span class='span_color'>元</span><del class='first_money'>" + n_tbk_item[i].reserve_price + "元</del></div>");
		html.push("<div class='library_commission'><span class='commission_color'>佣金<strong>3.47</strong></span><a href='' target='_blank'><span class='commission_direction'>定向50.3%</span></a><span class='Sales'>销量&nbsp;" + n_tbk_item[i].volume + "</span></div>");
		html.push("<div class='library_coupon'><ul><li><a target='_blank' style='color: #777777;' href=''>券<span class='red'>10</span>元</a></li><li><a target='_blank' style='color: #777777;' href=''>余<span class='red'>4054</span>张</a></li><li><a target='_blank' style='color: #777777;' href=''>已领<span>15946</span>张</a></li></ul></div>");
		html.push("<button class='button' id='selected92764' data-itemid='42607293163'><div>批量选取</div></button><a href=''><button class='button1'><div>单个推广</div></button></a><p class='library_statistics'> 近2小时跑单：<span>2035</span> / 券转化率：49.21%</p></div>");
		html.push("</li>");
	}
	$("#ulList").html(html.join(""));
}


</script>
<style>
    .library_class .get_more span{
        line-height: 22px;
        height: 20px;
        display: block;
        font-size: 18px;
    }
</style>
<div class="am-cf admin-main">
<div class="am-modal am-modal-alert" tabindex="-1" id="to_be_continued">
  <div class="am-modal-dialog">
    <div class="am-modal-hd" id="fq_alert_title"></div>
    <div class="am-modal-bd" id="fq_alert_info">即将上线！</div>
    <div class="am-modal-footer">
      <span class="am-modal-btn">朕知道了</span>
    </div>
  </div>
</div>


<!-- sidebar start -->
  <jsp:include page="commons/left.jsp" flush="true" />
<!-- sidebar end -->
<!-- content start -->
<div class="admin-content">
	<div class="admin-content-body">
	
		<div id="library_sort" style="height:0px;"></div>
        <div class="library_sort am-margin-top am-padding-horizontal">
            <div class="sort_btn">
                <div class="library_btn"><a href="" class="first active"><span>实时跑单</span></a></div>
	      <div class="library_btn"><a href="" class=""><span>券转化榜</span></a></div>
	      <div class="library_btn"><a href="" class=""><span>券飙升榜</span></a></div>
                <div class="library_btn"><a href="" class=""><span>人气宝贝</span></a></div>
                <div class="library_btn"><a href="" class="last "><span>全部商品</span></a></div>     
            </div>
            <div class="library_class">
                <a href="" class="category_active"><span>全部(120)</span></a>
                <a href="" class=""><span>女装(8)</span></a><a href="" class=""><span>男装(5)</span></a><a href="" class=""><span>内衣(8)</span></a><a href="" class=""><span>美妆(5)</span></a><a href="" class=""><span>配饰(14)</span></a><a href="" class=""><span>鞋品(3)</span></a><a href="" class=""><span>箱包(1)</span></a><a href="" class=""><span>儿童(10)</span></a><a href="" class=""><span>居家(22)</span></a><a href="" class=""><span>美食(9)</span></a><a href="" class=""><span>数码(4)</span></a><a href="" class=""><span>家电(4)</span></a><a href="" class=""><span>其他(27)</span></a>                <label class="am-checkbox-inline am-fr get_more am-hide " style="margin-top:4px;">
                    <input type="checkbox" id="more_items" data-am-ucheck="" name="more_items" value="/library/index/more_items/1.html" class="am-ucheck-checkbox"><span class="am-ucheck-icons"><i class="am-icon-unchecked"></i><i class="am-icon-checked"></i></span><span style="font-size:14px;display:inline;color: #777777;">（本页面默认展示最近三天产品）如需获取全部产品，请勾选</span>
                </label>
            </div>
            <div class="library_filter">
                <div class="library_sequence">
                    <p>排序：</p>
                    <div class="sequence_list">
                        <a id="all" href="javascript:void(0);" class="sort"><span>综合</span></a>
                        <a id="order_by_benefit" href="javascript:void(0);" class=" min_itemendprice"><span>优惠最多</span></a>
                        <a id="order_by_sales" href="javascript:void(0);" class=" max_itemsale"><span>销量最高</span></a>
                        <a id="order_by_commission" href="javascript:void(0);" class=" max_tkmoney"><span>佣金最高</span></a>
                        <a id="order_by_commissionrate" href="javascript:void(0);" class=" max_tkrates"><span>佣金比率最高</span></a>
                        <a id="order_by_finalprice" href="javascript:void(0);" class=" min_itemendprice"><span>券后价最低</span></a>        
                    </div>
                </div>
                <div class="library_select am-fr" id="library_select">
                    <label class="am-checkbox-inline">
                        <input type="checkbox" id="tianmao" data-am-ucheck="" name="tianmao" class="am-ucheck-checkbox"><span class="am-ucheck-icons"><i class="am-icon-unchecked"></i><i class="am-icon-checked"></i></span><span>天猫</span>
                    </label>
                    <form>
                    <div class="library_select_list" id="library_select_list">
                        <ul>
                            <li><span>价格区间</span><input type="number" id="itemendprice_min" value="" placeholder="￥" class="itemendprice_min">-<input type="number" id="itemendprice_max" placeholder="￥" value="" class="itemendprice_max"></li>
                            <li><span>销量区间</span><input type="number" id="itemsale_min" value="" class="itemsale_min">-<input type="number" id="itemsale_max" value="" class="itemsale_max"></li>
                            <li><span>佣金区间</span><input type="number" id="tkmoney_min" value="" class="tkmoney_min">-<input type="number" id="tkmoney_max" value="" class="tkmoney_max"></li>
                        </ul>
                    </div>
                    <button id="search_by_scope" type="button" class="filter am-fr">筛选</button>
                    </form>
                </div>
            </div>
            <div class="library_label">
                <div class="customize_label">
                    <div class="label_left" id="label_left">
                        <label class="am-checkbox-inline">
                            <input type="checkbox" id="nine" data-am-ucheck="" value="/library/index/more_items/0/nav/1/cid/0/sort/0/tianmao/0/nine/1/new_today/0/tjh/0.html" class="am-ucheck-checkbox"><span class="am-ucheck-icons"><i class="am-icon-unchecked"></i><i class="am-icon-checked"></i></span><span>九块九</span>
                        </label>
                        <label class="am-checkbox-inline">
                            <input type="checkbox" id="thirty" data-am-ucheck="" value="/library/index/more_items/0/nav/1/cid/0/sort/0/tianmao/0/thirty/1/new_today/0/tjh/0.html" class="am-ucheck-checkbox"><span class="am-ucheck-icons"><i class="am-icon-unchecked"></i><i class="am-icon-checked"></i></span><span>30封顶</span>
                        </label>
                        <label class="am-checkbox-inline">
                            <input type="checkbox" id="new_today" data-am-ucheck="" name="new_today" value="/library/index/more_items/0/nav/1/cid/0/sort/0/tianmao/0/nine/0/thirty/0/new_today/1/tjh/0.html" class="am-ucheck-checkbox"><span class="am-ucheck-icons"><i class="am-icon-unchecked"></i><i class="am-icon-checked"></i></span><span>今日上新</span>
                        </label>
                        <!--<label class="am-checkbox-inline">
                            <input type="checkbox"  id="tjh" data-am-ucheck name="tjh" value="/library/index/more_items/0/nav/1/cid/0/sort/0/tianmao/0/nine/0/thirty/0/new_today/0/tjh/1.html"  ><span>淘聚会</span>
                        </label>-->
                    </div>
                    <%--<div class="label_new ">
                        <button class="creat_title am-text-success">新建标签</button>
                                            </div>--%>
                </div>
                <div class="html_input">
                    <div class="html_val">
                        <div class="val_name">
                            <span>我的搜索标签</span>
                            <span class="val_name_off am-close-spin am-close" data-am-modal-close="">X</span>
                        </div>
                        
                        <div class="title_center">
                        <div class="name">
                            <div class="val_name_input">
                                <input type="text" class="am-form-field am-radius write_text" minlength="1" placeholder="字数不能超过7个字" maxlength="7" style="display:inline-block"><button class="am-btn am-btn-secondary am-btn-sm am-radius add_sub">添加</button><span class="add_warn">该标签已存在</span>
                            </div>
                            <p class="val_name_p_one">限8个标签，每个标签限7个字</p>
                            <div class="val_name_title">
                                <span class="am-fl val_name_start">我的标签：</span>
                            </div>
                            <div class="title_list">
                                <span>热门标签：</span>
                                <span class="hot_title">风扇</span>
                                <span class="hot_title">女包</span>
                                <span class="hot_title">化妆品</span>
                                <span class="hot_title">男装</span>
                            </div>
                        </div> 
						</div>
                        <div class="am-cf title_sub">
                            <button type="button" class="am-btn am-btn-secondary am-radius sub_title">提交保存</button>
                        </div>
                       
                    </div>
                </div>
                <div class="search_input">
                    <input id="search_input" type="text" placeholder="搜索商品" data-nav="1" onkeydown="if(event.keyCode==13){$('#search_button').click();}">
                    <button id="search_button">
                        <img src="${ctx}/assets/files/search.png">
                    </button>
                </div>
            </div>
        </div>
		
        <div class="buy_car">
            <div class="true">
                <img src="${ctx}/assets/files/true.png">
            </div>
            <div class="buy_number"><span>0</span></div>
            <a href="#library_sort" title="回到顶部"><div id="plus_one">+1</div></a>
        </div>
		
        <div class="buy_car_background">
            <div class="buy_car_list">
                <div class="buy_car_header">
                    <span>所选商品</span>
                    <img src="${ctx}/assets/files/off.png">
                </div>
                <div class="buy_car_main">
                </div>
                <div class="buy_car_button">
					<button type="reset" style="padding-top: 5px; 5px;font-size:15px;" class="am-btn  am-btn-danger am-btn-default close_modal">删除全部商品</button>
                    <button id="btn_items_select" type="button" style="padding-top: 5px;font-size:15px;" class="am-btn am-btn-success">批量推广</button>
                </div>
            </div>
        </div>
		
		<ul id="ulList" class="am-avg-sm-1 am-avg-md-2 am-avg-lg-3 am-avg-lgx-4 am-avg-hd-5 am-avg-full-6 am-padding-horizontal">
        </ul>
			
        <div class="am-cf"></div>
        <br>
        <div style="margin-left:700px;">
        <div id="Pagination" class="pagination" style=""></div>
        </div>

	</div>
	<footer class="admin-content-footer">
	<hr>
	<p class="am-padding-left">深圳前海刷云科技有限公司  CopyRight©2016  闽ICP备16026055号</p>
</footer>
</div>
<!-- content end -->
</div>

<script type="text/javascript">

//图片加载后的用户交互效果
window.onload=function(){
 $('.img_loading').hide();
 $('.img_loadend').show();
}

//获取更多商品
$('#more_items').click(function(){
    var more_val=$(this).val();
    window.location.href=more_val;
});

//九块九
/*$('#nine').click(function(){
    var nine_val=$(this).val();
    window.location.href=nine_val;
});

//30元封顶
$('#thirty').click(function(){
     var thirty_val=$(this).val();
    window.location.href=thirty_val;
});

//今日上新
$('#new_today').click(function(){
   var today_val=$(this).val();
    window.location.href=today_val;
});*/
//淘聚会店
$('#tjh').click(function(){
   var tjh_val=$(this).val();
    window.location.href=tjh_val;
});

//提交保存最新设置的自定义
$(".sub_title").click(function(){
    var val_name_p = $(".val_name_title").find(".val_name_p");
    var val_name_p1 = $(".val_name_title").find(".val_name_p");
    var nav = $('#search_input').attr('data-nav');
    $(".label_new").find(".val_name_p").remove();
    var keyword = new Array();
    for(var d=0;d<val_name_p.length;d++){
        var vala = val_name_p.eq(d).children('.name_span').text();
        keyword[d] = val_name_p.eq(d).children('.name_span').text();
        if($('#more_items').prop('checked')==true){
            $(".label_new button").before(
                "<p class='val_name_p'>"+
                "<a href='/Library/index/more_items/1/nav/3/keyword/"+vala+".html' style='color:#000'>"+"<span class='name_span'>"+vala+ "</span>"+
                "</p>"+"</a>"
            );
        }else{
             $(".label_new button").before(
                "<p class='val_name_p'>"+
                "<a href='/Library/index/nav/3/keyword/"+vala+".html' style='color:#000'>"+"<span class='name_span'>"+vala+ "</span>"+
                "</p>"+"</a>"
            );
        }
        
            
    };

    $.ajax({
        type:'post',
        url:"/library/api_create_title.html",
        data:{'keyword':keyword},
        success:function(data){
            if(data.status == 1){
                $("#fq_alert_info").html('保存成功');
                $('#fq_alert').modal();
            }
            if(data.status == 0){
                $("#fq_alert_info").html('保存失败');
                $('#fq_alert').modal();
            }
                
        }
    });
    if (val_name_p.length<=8&&val_name_p.length>0){
        $(".label_new button").text("管理标签");
    };
    if (val_name_p1.length==0){
        $(".label_new button").text("新建标签");
    }
    $(".html_input").hide();
        
});

</script>


</body></html>